package impl;

import anaydis.sort.SorterType;

import java.util.Comparator;
import java.util.List;

public class InsertionSorter extends AbstractSorter {

    public InsertionSorter() {
        super(SorterType.INSERTION);
    }

    public <T> void sort(Comparator<T> comparator, List<T> list) {
        int Tope = list.size();
        for (int i = 0; i < Tope; i++) {
            for (int j = i; j > 0; j--) {
                if (!greater(comparator,list,j,j -1)) {
                    swap(list, j, j - 1);
                } else {
                    break;
                }
            }
        }
    }


}
